package com.it.rabbitmqwithjiang.AckConfig;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.retry.MessageRecoverer;
import org.springframework.amqp.rabbit.retry.RepublishMessageRecoverer;
import org.springframework.context.annotation.Bean;

public class MessageRecovery {

    /*
    *     RejectAndDontRequeueRecoverer：重试耗尽后，直接 reject，丢弃消息。默认就是这种方式
          ImmediateRequeueMessageRecoverer：重试耗尽后，返回nack，消息重新入队
          RepublishMessageRecoverer：重试耗尽后，将失败消息投递到指定的交换机
          @这里我们选用 RepublishMessageRecoverer
    * * * */

    @Bean
    public MessageRecoverer republishMessageRecoverer(RabbitTemplate rabbitTemplate){
        return new RepublishMessageRecoverer(rabbitTemplate, "errorDirect", "errorqueue");
    }


}
